//
//  IconView.m
//  SDSY
//
//  Created by 蓝布鲁 on 2017/4/4.
//  Copyright (c) 2017 蓝布鲁. All rights reserved.
//

#import "IconView.h"

@implementation IconView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setTitleColor:UIColor.grayColor forState:UIControlStateNormal];
        self.titleLabel.font = [UIFont systemFontOfSize:12];

        // 设置为不可点击
        self.userInteractionEnabled = false;
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    // 向右移动title
    CGRect frame = self.titleLabel.frame;
    frame.origin.x += 5;
    self.titleLabel.frame = frame;
}

- (void)setText:(NSString *)text {
    [self setTitle:[NSString stringWithFormat:@"%@",text]forState:UIControlStateNormal];
    _text = text;
}

- (void)setIcon:(UIImage *)icon {
    [self setImage:icon forState:UIControlStateNormal];
    _icon = icon;
}

@end
